package com.meowcook.mapper;

import com.meowcook.pojo.dto.CookingAddDTO;
import com.meowcook.pojo.dto.CookingUpdateDTO;
import com.meowcook.pojo.po.Cooking;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 28792
 * Date: 2025-05-15
 * Time: 19:00
 */
@Mapper(componentModel = "spring")
public interface CookingPojoMapper {
    CookingPojoMapper INSTANCE = Mappers.getMapper(CookingPojoMapper.class);

    @Mappings({
            @Mapping(source = "stepNumber", target = "stepNumber"),
            @Mapping(source = "imageUrl", target = "imageUrl"),
            @Mapping(source = "title", target = "title"),
            @Mapping(source = "description", target = "description"),
            @Mapping(source = "timeRequired", target = "timeRequired"),
            @Mapping(source = "timeUnit", target = "timeUnit")
    })
    Cooking toPO(CookingAddDTO cookingAddDTO);

    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "stepNumber", target = "stepNumber"),
            @Mapping(source = "imageUrl", target = "imageUrl"),
            @Mapping(source = "title", target = "title"),
            @Mapping(source = "description", target = "description"),
            @Mapping(source = "timeRequired", target = "timeRequired"),
            @Mapping(source = "timeUnit", target = "timeUnit")
    })
    Cooking toPO(CookingUpdateDTO cookingUpdateDTO);

    @Mappings({
            @Mapping(source = "stepNumber", target = "stepNumber"),
            @Mapping(source = "imageUrl", target = "imageUrl"),
            @Mapping(source = "title", target = "title"),
            @Mapping(source = "description", target = "description"),
            @Mapping(source = "timeRequired", target = "timeRequired"),
            @Mapping(source = "timeUnit", target = "timeUnit")
    })
    List<Cooking> toPO(List<CookingAddDTO> cookingAddDTOS);

    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "stepNumber", target = "stepNumber"),
            @Mapping(source = "imageUrl", target = "imageUrl"),
            @Mapping(source = "title", target = "title"),
            @Mapping(source = "description", target = "description"),
            @Mapping(source = "timeRequired", target = "timeRequired"),
            @Mapping(source = "timeUnit", target = "timeUnit")
    })
    List<Cooking> updateToPO(List<CookingUpdateDTO> cookingUpdateDTOS);
}
